
function init(){
	$("#grid").kendoGrid({
	     dataSource: {
	         type: "json",
	         transport: {
	        	 read: {
	                 url: urlSearch,
	                 dataType: "json",
	                 type: "get",
	                 data : {}
	             },
	         },
	         //pageSize: 10,
	         schema:{
		        data: "list",
		        total: function(data) {
	                return data.total;
	            },
	    	 },
	    	 group: {
                 field: "dateValue", aggregates: [
                    { field: "totalPrice", aggregate: "sum"},
                 ]
	    	 },
	    	 /*
	    	 aggregate: [
	             { field: "totalPrice", aggregate: "sum" },
	         ],*/
	    	 requestStart: function(e) {   
                e.sender.transport.options.read.data = utils.getParamsForSearch("frmSearch");
             },
    	     pageSize: 20,
    	     serverPaging: true,
	     },	    
	     sortable: false,         
         //groupable: true,
         pageable: {
             refresh: true,
             //pageSizes: true,
         },
	     columns: [{
	    	 title: "Date",
	         field: "dateValue",
	         width: 120,
	         groupFooterTemplate: "Total",
	     },{
	         field: "type",
	         title: "Type",
	         width: 80
	     }, {
	    	 title: "id",
	         field: "productId",
	         width: 100
	     }, {
	    	 title: "Name",
	         field: "productName",
	         width: 200
	     },{
	         field: "totalQuantity",
	         title: "Item nums",
	         width: 100,
	     },{
	    	 title: "User nums",
	         field: "totalUser",
	         width: 100,
	     },{
	         field: "totalPrice",
	         title: "Total coin",
	         width: 100,
	         format: "{0:n0}",
	         groupFooterTemplate: "#=kendo.toString(sum, 'n0')#",
	         //footerTemplate: "#=sum#"
	     },{
	         field: "",
	         title: "",
	     }], 
	     dataBound : function(e){
	    	
	     }
	});
}

function setAutoRefreshGrid(second)
{
	if(typeof(second) == "undefined")
		second = 10;
		
	setInterval(function(){
		$("#grid").data("kendoGrid").dataSource.read();
	}, second * 1000);
}

function search(){
	$("#grid").data("kendoGrid").dataSource.read();	// Reset grid
	
}